from toee import *
from scripts import *

def san_dialog( attachee, triggerer ):
	if ( game.quests[60].state == qs_completed and game.global_flags[315] == 1 ):
		triggerer.begin_dialog(attachee,400)
	elif ( not attachee.has_met(triggerer) ):
		if game.quests[35].state == qs_completed:
			triggerer.begin_dialog(attachee,300)
		else:
			triggerer.begin_dialog(attachee,1)
	elif ( game.quests[60].state == qs_botched ):
		triggerer.begin_dialog(attachee,260)
	elif ( game.global_flags[317] == 1 ):
		triggerer.begin_dialog(attachee,330)
	elif ( game.quests[60].state <= qs_mentioned ):
		triggerer.begin_dialog(attachee,470)
	else:
		triggerer.begin_dialog(attachee,200)
	return SKIP_DEFAULT

def san_heartbeat(attachee, triggerer):
	if ( game.quests[60].state == qs_completed and game.global_flags[315] == 1 ):
		if (attachee.map == 5051):
			attachee.object_flag_set(OF_OFF)
		if (attachee.map == 5160):
			attachee.object_flag_unset(OF_OFF)
	return RUN_DEFAULT

def san_dying( attachee, triggerer ):
	game.quests[60].state = qs_botched
	return RUN_DEFAULT

def buttin( attachee, triggerer, line):
	npc = find_npc_near(attachee,8015)
	if (npc != OBJ_HANDLE_NULL):
		triggerer.begin_dialog(npc,line)
		npc.turn_towards(attachee)
		attachee.turn_towards(npc)
	else:
		triggerer.begin_dialog(attachee,150)
	return SKIP_DEFAULT
